/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Servlet.purchase;

import Model.Purchase.PurchaseList;
import Model.Purchase.PurchaseListView;
import RssEasy.Core.HttpRequestHelper;
import RssEasy.Core.SignVerifyRequestHelper;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Administrator
 */
@WebServlet(name = "api_purchase_change", urlPatterns = {"/api/purchase/change"})
public class purchase extends SignVerifyRequestHelper {
    
    @Override
    protected HttpRequestHelper request(HttpServletRequest request, HttpServletResponse response) {
        super.request(request, response); //To change body of generated methods, choose Tools | Templates.

        try {
            PurchaseListView list = new PurchaseListView(pageContext);
            list.select("id as purid,corpname,name as purname,enddt,linkname").where("id in (" + this.get("ids") + ")").query();
            out.print(list.toKeyValue());
        } catch (Exception e) {
            out.print("{\"error\":\"" + e.getMessage() + "\"}");
        }
        
        return this;
    }
}
